﻿using IcicleFramework.Components.Health;
using Microsoft.Xna.Framework;

namespace IcicleFramework.Actions.Damage
{
    public class BasicDamageAction : GameAction
    {
        public float Damage { get; set; }

        public BasicDamageAction() { }

        protected BasicDamageAction(BasicDamageAction old)
            :base(old)
        {
            this.Damage = old.Damage;
        }

        public override void Update(GameTime gameTime)
        {
            var healthComponent = Target.GetComponent<IHealthComponent>();

            if (healthComponent != null)
            {
                healthComponent.Damage(Damage, Parent);
            }
        }

        public override IGameAction DeepClone()
        {
            return new BasicDamageAction(this);
        }
    }
}
